<?php
	session_start();
	
	if (!isset($_SESSION['login']) && !$_SESSION['login'] == true) {
		header ("Location: index.php");
	}
	
	
	include 'config.php';
	mysqli_set_charset($con, 'utf8');
	
	// Check connection
	if (mysqli_connect_errno())
	{
		echo "Failed to connect to MySQL: " . mysqli_connect_error();
	}
	
	$OwnerID = $_SESSION['userid'];
	$Name = $_POST['Project'];
	$ContactName = $_POST['Contact'];
	$CustomerName = $_POST['Customer'];
	$OwnerRole = $_POST['OwnerRole'];
	$StatusID = 2;
	$Recommendation = $_POST['Recommendation'];
	$Problem = $_POST['Problem'];
	$Solution = $_POST['Solution'];
	$CustomerValue = $_POST['CustomerValue'];
	$NextStep = $_POST['NextStep'];
	$TimeFrame = $_POST['TimeFrame'];
	
	$sql = "INSERT INTO `Innovation` (`OwnerID`, `Name`,`ContactName`, `CustomerName`, `OwnerRoleID`, `StatusID`, `Recommendation`, `Problem`, `Solution`, `CustomerValue`, `NextStepID`, `TimeFrameID`) VALUES ('$OwnerID','$Name','$ContactName','$CustomerName', '$OwnerRole', '$StatusID','$Recommendation','$Problem','$Solution','$CustomerValue','$NextStep','$TimeFrame')";
	
	if (!mysqli_query($con,$sql))
	{
		die('Error: ' . mysqli_error($con));
	}

	mysqli_close($con);
	
	$_SESSION['Popup'] = "En ny rekommendation har skapats";
	
	header ("Location: listinnovation.php");

?>